#include "FKFileManager.h"

//#include <QDataStream>
#include <QVariant>

#include "FKLogger.h"

const qint64 FKFileManager::blockSize=102400;
QString FKFileManager::_rootPath;

FKFileManager::FKFileManager(QObject *parent):QObject(parent){
    FK_CBEGIN
    FK_CEND
}

FKFileManager::~FKFileManager(){
    FK_DBEGIN
    FK_DEND
}

void FKFileManager::setRootPath(QString rootPath){
    _rootPath=rootPath;
}

QVariant FKFileManager::packVar(FKFileManager::Mark mark, const QString &file, const QVariant& var){
    QList<QVariant> lst;
    lst<<QVariant(static_cast<int>(mark))<<file<<var;
    return lst;
}

FKFileManager::Mark FKFileManager::unpackVar(QString &file, QVariant &var){
    QList<QVariant> lst=var.toList();
    if(lst.size()==3){
        file=lst.at(1).toString();
        var=lst.at(2);
        return static_cast<FKFileManager::Mark>(lst.at(0).toInt());
    }else{
        FK_MLOG("invalid file manager message size")
        return errorOne;
    }
}
